#pragma once

// CPlayerImpl command target
#include "LopApi.h"
interface IGraphBuilder2;


class CPlayerImpl : public CObject
{
public:
	CPlayerImpl(CWnd* pWndNotify);
	virtual ~CPlayerImpl();

	//
	HRESULT PlayMovieInWindow(LPCTSTR szFile, HWND hwndVieo);
	void Pause(void);
	void Stop(void);
	void Close();
	//
	LOP_PLAYSTATE GetState() const	{return m_psCurrent;}
	//
	HRESULT HandleGraphEvent(LPARAM lParam);
	//
	HRESULT InitVideoWindow(int nMultiplier, int nDivider);

	void SetVideoWindowPos(LPCRECT lpRect);
protected:
	void SetState(LOP_PLAYSTATE val)	{m_psCurrent = val;}
	void CheckVisibility(void);
	HRESULT InitPlayerWindow(void);
	void CloseInterfaces(void);
private:
	void Init ();
private:
	CWnd*			m_pWndNotify;
	BOOL			m_bAudioOnly;
	BOOL			m_bFullscreen;
	LONG			m_lVolume;
	DOUBLE			m_PlaybackRate;
	LOP_PLAYSTATE	m_psCurrent;

	CComPtr<IGraphBuilder2>		m_pGB;
	CComPtr<IMediaControl>		m_pMC;
	CComPtr<IMediaEventEx>		m_pME;
	CComPtr<IVideoWindow>		m_pVW;
	CComPtr<IBasicAudio>		m_pBA;
	CComPtr<IBasicVideo>		m_pBV;
	CComPtr<IMediaSeeking>		m_pMS;
	CComPtr<IMediaPosition>		m_pMP;
	CComPtr<IVideoFrameStep>	m_pFS;
};


